var config = require('../../../../utils/config.js');
var util = require('../../../../utils/util');
var API_URL = config.API_URL;
var userInfo, money_src_type;
var app = getApp();
Page({
  data: {

  },
  onLoad: function (options) {
    console.log(options)
    userInfo = my.getStorageSync({key:'user'}).data;
    money_src_type = options.money_src_type;
  },
   onShow: function () {
    var that = this;
    my.httpRequest({
      url: API_URL.my_card,
      data: {
        user_id: userInfo.userId
      },
      method: 'POST',
      success: function (res) {
        console.log(res)
        if (res.data.status == 200) {
          var cards = res.data.data.cards.map(item => {
            item.move = false;
            switch (item.backName) {
              case "中国民生银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/1.png'; break;
              case "平安银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/2.png'; break;
              case "中国银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/3.png'; break;
              case "中国邮政储蓄": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/4.png'; break;
              case "光大银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/5.png'; break;
              case "浙商银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/6.png'; break;
              case "东亚银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/7.png'; break;
              case "上海银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/8.png'; break;
              case "中国工商银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/9.png'; break;
              case "中国建设银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/10.png'; break;
              case "中国农业银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/11.png'; break;
              case "中国交通银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/12.png'; break;
              case "华夏银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/13.png'; break;
              case "招商银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/14.png'; break;
              case "中信实业银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/15.png'; break;
              case "上海浦东发展银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/16.png'; break;
              case "广州市商业银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/17.png'; break;
              case "北京银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/18.png'; break;
              case "大连银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/19.png'; break;
              case "宁波银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/20.png'; break;
              case "青岛银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/21.png'; break;
              case "深圳发展银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/22/1.png'; break;
              case "盛京银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/23.png'; break;
              case "中国人民银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/24.png'; break;
              case "广发银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/25.png'; break;
              case "农村信用社": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/26.png'; break;
              case "天津银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/27.png'; break;
              case "兴业银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/28.png'; break;
              case "长安银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/29.png'; break;
              case "中国农业发展银行": item.img = 'http://nan.jade-box.com/wxapp_img/bank/new/30.png'; break;
            }
            return item;
          })
          res.data.data.cards = cards;
          that.setData(res.data.data);
        } else {
          util.showNotice('网络错误')
        }
      },
      fail: function (res) {
        util.showNotice('网络错误')
      },
      complete: function (res) { },
    })
  },
  // 去添加银行卡
    goToAdd: function (e) {
   my.navigateTo({
      url: '/pages/user/card/add/add',
    })
  },

})